package com.mingqijia.gassafety.console.controller.inner;


import com.gap.basic.base.CommonResponse;
import com.mingqijia.gassafety.webserver.request.AddFieldShowRequest;
import com.mingqijia.gassafety.webserver.request.inner.AddressTurnCoordinateReq;
import com.mingqijia.gassafety.webserver.service.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
/**
 * @date 2024/6/18 11:10
 * 统一自定义常量字段类
 */
@Slf4j
@Api(tags = "公共内部处理数据接口")
@RestController
@RequestMapping("/inner/v1/dispose/data")
public class DisposeDataController {

    @Autowired
    private FieldListShowService fieldListShowService;

    @Autowired
    private ConsumerService consumerService;

    @Autowired
    private ConsumerLocationService consumerLocationService;

    @Autowired
    EquipmentService equipmentService;

    @Autowired
    private FunctionAreaService functionAreaService;

    @Autowired
    private DivisionService divisionService;

    private ExecutorService executor = Executors.newFixedThreadPool(200);

    @ApiOperation("新增字段接口")
    @PostMapping(value = "/add/field", name = "新增字段接口")
    public CommonResponse<Object> addField(@RequestBody AddFieldShowRequest request) {
        fieldListShowService.addListShow(request);
        return CommonResponse.success("success");
    }

    @PostMapping("/syncConsumer")
    @ApiOperation(value = "客户表高德转百度")
    public CommonResponse<Object> syncConsumer() {
        log.info("开始进入客户表高德转百度");
        consumerService.syncConsumer();
        return CommonResponse.success("success");
    }

    @PostMapping("/syncConsumerLocation")
    @ApiOperation(value = "客户位置表高德转百度")
    public CommonResponse<Object> syncConsumerLocation() {
        log.info("开始进入客户位置表高德转百度");
        consumerLocationService.syncConsumerLocation();
        return CommonResponse.success("success");
    }

    @PostMapping("/syncConsumerLocationCode")
    @ApiOperation(value = "客户位置表编码转换")
    public CommonResponse<Object> syncConsumerLocationCode() {
        log.info("开始进入客户位置表编码转换");
        consumerLocationService.syncConsumerLocationCode();
        return CommonResponse.success("success");
    }

    @PostMapping("/syncDtu")
    @ApiOperation(value = "设备表高德转百度")
    public CommonResponse<Object> syncDtu() {
        log.info("开始进入设备表高德转百度");
        equipmentService.syncDtu();
        return CommonResponse.success("success");
    }

    @PostMapping("/syncArea")
    @ApiOperation(value = "区域表高德转百度")
    public CommonResponse<Object> syncArea() {
        log.info("开始进入客户表高德转百度");
        functionAreaService.syncArea();
        return CommonResponse.success("success");
    }

    @PostMapping("/syncDivision")
    @ApiOperation(value = "行政区划表高德转百度")
    public CommonResponse<Object> syncDivision() {
        log.info("开始进入行政区划表高德转百度");
        divisionService.syncDivision();
        return CommonResponse.success("success");
    }

    @PostMapping("/address/turn/coordinate")
    @ApiOperation(value = "根据地址转坐标和编码")
    public CommonResponse<Object> addressTurnCoordinate(@RequestBody AddressTurnCoordinateReq req) {
        log.info("根据地址转坐标和编码");
        consumerService.addressTurnCoordinate(req);
        return CommonResponse.success("success");
    }

}
